﻿<Window x:Class="Demo.UIAnnotationsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:uia="clr-namespace:Thinktecture.UIAnnotations;assembly=Thinktecture.UIAnnotations"
        Title="Thinktecture.UIAnnotations Demo" Height="360" Width="525" MinHeight="360" MinWidth="525" WindowStartupLocation="CenterScreen"
        FontFamily="Calibri" FontSize="14" TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display" UseLayoutRounding="True"
        uia:Annotations.ApplyDataAnnotations="True"
        uia:Annotations.DescriptionDisplayControl="{Binding ElementName=descriptionLabel}"
        uia:Annotations.DescriptionDefaultText="Ready." Icon="/Demo;component/Contact.ico">

    <Window.Resources>
        <ContextMenu x:Key="editSmartTagMenu">
            <MenuItem Name="checkNameMenuItem" Header="_Validate Name" Click="checkNameMenuItem_Click">
                <MenuItem.Icon>
                    <Image Source="/Images/Check.png" />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Name="searchNameMenuItem" Header="_Search for Name" Click="searchNameMenuItem_Click">
                <MenuItem.Icon>
                    <Image Source="/Images/Search.png" />
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>

        <ContextMenu x:Key="imageSmartTagMenu">
            <MenuItem Name="saveImageMenuItem" Header="_Save Image" Click="saveImageMenuItem_Click">
                <MenuItem.Icon>
                    <Image Source="/Images/Save.png" />
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>

        <!--assign annotations via style-->
        <Style x:Key="textBoxStyle"  TargetType="{x:Type TextBox}">
            <Setter Property="uia:Annotations.HighlightOnFocus" Value="True" />
            <Setter Property="uia:Annotations.RequiredImageAlignment" Value="Right" />
            <Setter Property="uia:Annotations.ShowEditTracker" Value="True" />
            <Setter Property="uia:Annotations.ShowElementTracker" Value="True" />
            <Setter Property="uia:Annotations.TrackerImageAlignment" Value="Left" />
            <Setter Property="uia:Annotations.AttachErrorTemplate" Value="True" />
            <Setter Property="uia:Annotations.AttachEditContextMenu" Value="True" />
            <Setter Property="uia:Annotations.AttachEditorToolbar" Value="True" />
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="28" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
            <ColumnDefinition Width="28"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="28" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label Grid.Row="1" Grid.Column="1" Content="ID:" />
        <TextBox x:Name="idTextBox" Grid.Row="1" Grid.Column="2" MinWidth="70" HorizontalAlignment="Left" Margin="25,5,20,0" 
                 Text="{Binding Path=Id, Mode=OneWay}"
                 Style="{StaticResource textBoxStyle}">
        </TextBox>

        <Label Grid.Row="2" Grid.Column="1" Content="_Name:" />
        <TextBox x:Name="nameTextBox" Grid.Row="2" Grid.Column="2" Margin="25,5,20,0" 
                 Text="{Binding Path=Name, Mode=TwoWay, ValidatesOnDataErrors=True}"
                 Style="{StaticResource textBoxStyle}"
                 uia:Annotations.CueBanner="Enter the full name!" 
                 uia:Annotations.AttachSmartTag="True"
                 uia:Annotations.SmartTagMenu="{StaticResource editSmartTagMenu}" />

        <Label Grid.Row="3" Grid.Column="1" Content="_Birthday:" />
        <DatePicker x:Name="birthdayDatePicker" Grid.Row="3" Grid.Column="2" Margin="25,5,20,0" 
                 SelectedDate="{Binding Path=Birthday, Mode=TwoWay, ValidatesOnDataErrors=True}"
                 uia:Annotations.HighlightOnFocus="True" 
                 uia:Annotations.RequiredImageAlignment="Right"
                 uia:Annotations.ShowEditTracker="True"
                 uia:Annotations.ShowElementTracker="True"
                 uia:Annotations.TrackerImageAlignment="Left"
                 uia:Annotations.AttachErrorTemplate="True"
                 uia:Annotations.AttachEditorToolbar="True"
                 uia:Annotations.AttachEditContextMenu="True" 
                 uia:Annotations.CueBanner="Choose a date!" />

        <Label Grid.Row="4" Grid.Column="1" Content="_Department:" />
        <ComboBox Grid.Row="4" Grid.Column="2" Margin="25,5,20,0" Name="departmentComboBox" DisplayMemberPath="Name"
                  IsEditable="True" SelectedItem="{Binding Path=Department, ValidatesOnDataErrors=True}"
                  ItemsSource="{Binding Departments}"
                 uia:Annotations.HighlightOnFocus="True"
                 uia:Annotations.RequiredImageAlignment="Right"
                 uia:Annotations.ShowEditTracker="True"
                 uia:Annotations.ShowElementTracker="True"
                 uia:Annotations.TrackerImageAlignment="Left"
                 uia:Annotations.AttachErrorTemplate="True"
                 uia:Annotations.AttachEditorToolbar="True"
                 uia:Annotations.AttachEditContextMenu="True"
                 uia:Annotations.CueBanner="Select a department!" />

        <Label Grid.Row="5" Grid.Column="1" Content="Photo:" />
        <Border Grid.Column="2" Grid.Row="5" BorderBrush="LightBlue" BorderThickness="1" Height="110" HorizontalAlignment="Left" Margin="25,5,20,0" VerticalAlignment="Top">
            <Image Name="photoImage" Source="/Demo;component/Images/jone_130x160.png" 
                   uia:Annotations.AttachSmartTag="True"
                   uia:Annotations.SmartTagMenu="{StaticResource imageSmartTagMenu}" />
        </Border>

        <StackPanel Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6" Orientation="Horizontal" Margin="0,10,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Right"></StackPanel>

        <StatusBar x:Name="statusBar1" Grid.ColumnSpan="4" Grid.Row="7" Margin="0,10,0,0" VerticalAlignment="Bottom" FontFamily="Calibri">
            <StatusBar.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFE5EBF5" Offset="0" />
                    <GradientStop Color="#FFABC4FC" Offset="1" />
                </LinearGradientBrush>
            </StatusBar.Background>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                <Image Source="/Images/Infos.png" Stretch="None" Margin="2,4,0,0" />
                <Label Name="descriptionLabel" Content="Ready." VerticalAlignment="Center" Margin="0,0,0,0" FontFamily="Calibri" FontSize="14" />
            </StackPanel>
        </StatusBar>
    </Grid>

    <Window.Background>
        <RadialGradientBrush>
            <GradientStop Color="White" Offset="0" />
            <GradientStop Color="#FFCDD6EF" Offset="1" />
        </RadialGradientBrush>
    </Window.Background>
</Window>
